<%@page import="com.assg2.dao.DaoViewer"%>
<%@page import="com.movie.Book"%>
<%@page import="com.movie.Viewer"%>
<%@page import="com.movie.Show"%>
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.movie.Movie"%>
<%@page import="com.enterprise.web.*"%>
<%@page contentType="text/html"%>

<jsp:useBean id="ListBooking" class="com.assg2.dao.DaoBook" />
<jsp:useBean id="Movie" class="com.movie.Movie" />
<jsp:useBean id="Show" class="com.movie.Show" />
<jsp:useBean id="Book" class="com.movie.Book" />
<jsp:useBean id="Viewer" class="com.movie.Viewer" />


<%@include file="headerv.html"%>

<h3>Welcome to <b>Cinema World,</b> <span> This are your current bookings</span></h3>

<%
    List<Book> booklist = new ArrayList<Book>();
    Viewer v = null;
    DaoViewer dv = new DaoViewer();
    String usertype = (String) session.getAttribute("usertype");
    if (usertype.matches("viewer")) {
        v = (Viewer) session.getAttribute("user");
        v = (Viewer) dv.findById(v.getIdviewer());
    }

    if (v != null) {
        booklist = ListBooking.BookinList(v);
        out.println("<br><CENTER><h1>Booking List</h1></CENTER><br>");
        out.println("<center><table width='700px' border='0'>");
        out.println("<tr>");
        out.println("<td>");
        out.println("Cinema");
        out.println("</td>");
        out.println("<td>");
        out.println("Movie");
        out.println("</td>");
        out.println("<td>");
        out.println("Booking Number");
        out.println("</td>");
        out.println("<td>");
        out.println("Number of Seats");
        out.println("</td>");
        out.println("<td>");
        out.println("Confirmed");
        out.println("</td>");
        out.println("</tr>");

        for (Book book : booklist) {
            if (new java.util.Date().after(book.getDate())) {
                out.println("<tr>");
                out.println("<td>");
                out.println(book.getShow().getRoom().getCinema().getLocation());
                out.println("</td>");
                out.println("<td>");
                out.println(book.getShow().getMovie().getTitle());
                out.println("</td>");
                out.println("<td>");
                out.println(book.getShowIdshow());
                out.println("</td>");
                out.println("<td>");
                out.println(book.getNumberofseats());
                out.println("</td>");
                out.println("<td>");
                if (book.getConfirm()) {
                    out.println("Yes");
                } else {
                    out.println("No");
                }
                out.println("</td>");
                out.println("</tr>");
            }
        }
        out.println("</table></center>");
    }





%>
<%@include file="footer.html"%>
